package com.leon.spring_security_oauth2.auth_util;

import com.leon.spring_security_oauth2.service.SysUserService;
import com.leon.spring_security_oauth2.vo.UserVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;


@Service("userDetailsService")
public class UserDetailServiceImpl implements UserDetailsService {
    @Autowired
    private SysUserService sysUserService;

    @Override
    public UserDetailsImpl loadUserByUsername(String username) throws UsernameNotFoundException {
        UserVO userVo = sysUserService.findUserByUsername(username);
        return new UserDetailsImpl(userVo);
    }
}
